Skip to content

refactor(harness): extract retained workspace scope owners (SAP-3091) - #909

Open
ynadge wants to merge 2 commits into
yashnadge/sap-3090-delete-browser-graph-topologyfrom
yashnadge/sap-3091-extract-workspace-scope-owners
Open

refactor(harness): extract retained workspace scope owners (SAP-3091)#909
ynadge wants to merge 2 commits into
yashnadge/sap-3090-delete-browser-graph-topologyfrom
yashnadge/sap-3091-extract-workspace-scope-owners

Conversation

@ynadge

@ynadge ynadge commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Primary change type

  • Bug fix
  • Documentation
  • Feature
  • Tests
  • Dependency update
  • Maintenance or refactor

Problem and motivation

Workspace identity, allowed-root resolution and per-agent invocation types were still owned by mixed legacy graph modules. Deleting those modules directly would remove contracts used by current Studio discovery and Canvas.

Summary and scope

Extract workspace scope types and local identity helpers into shared/workspace-scope.ts, the catalog into core/workspace-scope-catalog.ts, and containment helpers into core/workspace-path.ts. Move AgentInvocationMode to Canvas ownership. Repoint live imports, browser aliases and the existing public type export; temporary legacy re-exports keep this boundary buildable.

Related work

Related issue or discussion: SAP-3091. Part of the authorized cleanup stack above #892 and #893, targeting main. The seven layers are intended to merge and ship together. Updated layers require maintainer approval before merge.

Validation

Review-fix verification on cumulative source 5bfed981, including current main (8679d745). Server and browser typechecks also passed on each of the seven isolated PR heads.

pnpm --filter '@sapiom/harness...' build — passed
pnpm --filter @sapiom/harness typecheck — passed
pnpm --filter @sapiom/harness lint — passed
pnpm --filter @sapiom/harness exec vitest run --maxWorkers=2 — 3,845 passed, 2 skipped
pnpm --filter @sapiom/harness test:perf — 10 passed
pnpm --filter @sapiom/harness exec playwright test --config <local Chrome override> --workers=2 — 634 passed
pnpm --filter @sapiom/harness exec playwright test --config <Canvas Chrome override> --workers=2 — 15 passed
pnpm terminology:check — passed
pnpm provider-copy:check — passed

The browser override selects the installed Google Chrome, temporary output paths and pnpm exec vite; it preserves the checked-in tests and assertions. All 16 focused map/style/project-tab cases passed, including light/dark computed styles, project/agent viewport restoration, offscreen recovery, automatic fitting, auth isolation and layout recovery. The viewport and metadata regressions failed before their fixes. The new viewport and project-altitude tests also passed on #907's own intermediate tree (10 cases).

An initial three-worker Harness run failed one archive-wiring case; the affected file passed unchanged 8/8, followed by the complete passing two-worker run above. The main integration passed 263 focused cases, and #892's resolved auth mock passed 4/4 on its own tree. No tests or admission guards were weakened.

All PR heads include main's deliberate removal of the duplicate Claude workflow in #886. The reviewed commits remain in history; the stack update uses ordinary fast-forward pushes. Fresh build hashes and the earlier package/smoke evidence are recorded in the retirement record. Signed macOS installer/upgrade validation remains SAP-3086.

CI follow-up: the first Node 20 run hit the same archive-wiring failure noted above and cancelled Node 22 through matrix fail-fast. The unchanged rerun passed on both Node 20 and Node 22. The archive test, reader, writer and event store match main byte-for-byte.

Tests and documentation

Retained workspace identity, catalog, source containment, public export and per-agent Canvas tests remain at their neutral owners. The moved logic is unchanged.

Compatibility and release impact

  • Breaking or externally visible changes: Retained public WorkspaceScopeSummary and PackageInventory shapes are unchanged. This is an internal ownership move with no runtime migration.
  • Changeset: N/A — internal module/type moves preserve the existing public API and ship with the surrounding cleanup changesets.

Security

  • I have not included secrets, credentials, private data, or unsanitized logs.
  • This pull request does not publicly disclose a suspected vulnerability. I will follow the Security Policy for private reporting.

AI assistance

  • I did not use AI assistance for this change.
  • I used AI assistance and have described it below.

Codex implemented the cleanup and test/doc migrations, traced retained callers, and checked the resulting diffs. Automated checks above and independent read-only review provide implementation evidence; maintainer review is still required.

Checklist

  • I read CONTRIBUTING.md, and this contribution follows the direct-PR or issue-first policy.
  • This pull request addresses one focused problem and contains no unrelated cleanup.
  • I added or updated tests, or explained above why tests are not applicable.
  • I ran the relevant build, typecheck, lint, and test commands, or explained any N/A checks above.
  • I updated documentation for user-facing changes, or marked it N/A above.
  • I added a Changeset for a published-package change, or explained why it is not applicable.
  • I can explain and maintain every submitted change, including any AI-assisted work.

@ynadge
ynadge added this pull request to stack #894 September 9, 2026 23:15
@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 28b4818f-d088-4eb9-8540-1e9423402ac0

📥 Commits

Reviewing files that changed from the base of the PR and between 62c2ffd and b43e79c.

📒 Files selected for processing (31)
  • docs/plans/agent-studio-plan-first-agent-map/authority-retirement.md
  • packages/harness/src/core/canvas-interconnections.ts
  • packages/harness/src/core/studio-project-catalog.ts
  • packages/harness/src/core/studio-workspace-preferences.ts
  • packages/harness/src/core/system-graph-inventory.test.ts
  • packages/harness/src/core/system-graph-inventory.ts
  • packages/harness/src/core/system-graph.test.ts
  • packages/harness/src/core/system-graph.ts
  • packages/harness/src/core/workspace-path.test.ts
  • packages/harness/src/core/workspace-path.ts
  • packages/harness/src/core/workspace-scope-catalog.test.ts
  • packages/harness/src/core/workspace-scope-catalog.ts
  • packages/harness/src/index.ts
  • packages/harness/src/server/agent-map.ts
  • packages/harness/src/server/index.ts
  • packages/harness/src/server/rest.ts
  • packages/harness/src/shared/system-graph.ts
  • packages/harness/src/shared/types.ts
  • packages/harness/src/shared/workspace-scope.test.ts
  • packages/harness/src/shared/workspace-scope.ts
  • packages/harness/vitest.config.ts
  • packages/harness/web/src/App.tsx
  • packages/harness/web/src/components/ProjectTreeRows.tsx
  • packages/harness/web/src/components/WorkflowsRail.tsx
  • packages/harness/web/src/lib/agent-map.ts
  • packages/harness/web/src/lib/api.ts
  • packages/harness/web/src/lib/canvas-altitude.test.ts
  • packages/harness/web/src/lib/canvas-altitude.ts
  • packages/harness/web/src/lib/navigation-history.ts
  • packages/harness/web/tsconfig.json
  • packages/harness/web/vite.config.ts
💤 Files with no reviewable changes (2)
  • packages/harness/src/core/system-graph.test.ts
  • packages/harness/src/core/system-graph-inventory.test.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change moves workspace scope contracts, path handling, and catalog logic into dedicated modules. Server invalidation and refresh flows use the new workspace helpers. Harness web imports and aliases now reference the new workspace-scope module.

Changes

Workspace scope refactor

Layer / File(s) Summary
Workspace scope contracts and path utilities
packages/harness/src/shared/workspace-scope.ts, packages/harness/src/core/workspace-path.ts, related tests
Adds workspace scope metadata, local key generation, cross-platform path parsing, containment checks, canonical source-root selection, and tests.
Workspace catalog and inventory ownership
packages/harness/src/core/workspace-scope-catalog.ts, packages/harness/src/core/system-graph.ts, packages/harness/src/core/system-graph-inventory.ts, related tests
Moves workspace catalog contracts and implementation into dedicated modules. System-graph inventory re-exports the migrated types and helpers.
Server workspace containment integration
packages/harness/src/server/index.ts, packages/harness/src/server/*.ts, packages/harness/src/shared/types.ts
Updates invalidation, refresh matching, watcher selection, and graph inventory handling to use workspace-specific containment and source-root helpers.
Consumer and alias migration
packages/harness/web/src/*, packages/harness/*config*, docs/plans/.../authority-retirement.md
Changes workspace type imports and aliases to use workspace-scope, and documents retained module ownership.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested reviewers: gwitwer

Merge Risk: ⚪ Minimal · up to b43e7

This refactor preserves the workspace scope and inventory shapes while moving their ownership to dedicated modules. Path-boundary and catalog coverage accompany the migration, and no concrete merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 27 files. (2 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the refactor and the retained workspace scope ownership change.
Description check ✅ Passed The description includes all required sections, explains the focused scope, links related work, records validation, documents compatibility and security impact, and identifies AI assistance.
Full details: Docstring Coverage

Explanation

Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 27 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch yashnadge/sap-3091-extract-workspace-scope-owners

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit hops where scope keys gleam
New paths guide the workspace stream
Catalogs sort roots neat and bright
Graphs keep only what fits in sight
Imports follow their modules home
And tidy trails through code now roam

Comment @coderabbitai help to get the list of available commands.

@ynadge
ynadge marked this pull request as ready for review September 10, 2026 03:33

@gwitwer gwitwer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. Compared the moved bodies against the originals: identical logic, identifier renames only. WorkspaceScopeSummary export repointed with an unchanged shape; the @shared alias is updated consistently across tsconfig, vite and vitest; the removed test cases are exactly the ones re-homed into the three new files.

Preserve the reviewed history while updating the stack for review fixes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants